<button class="btn btn-success btn-xs" data-toggle="modal" data-target="#taskForward{{ $id }}">任务转赠</button>

<div class="modal fade" id="taskForward{{ $id }}" tabindex="-1" role="dialog" aria-labelledby="taskForward"
     aria-hidden="true">
    <div class="modal-dialog modal-xs">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true" style="font-size: 36px;">&times;</button>
                <h4 class="modal-title" id="myModalLabel">任务转赠</h4>
            </div>
            <div class="modal-body">
                <div class="mb-3">
                    <label for="exampleFormControlInput1" class="form-label">接收方</label>
                    <select type="text" name="followUserId{{ $id }}" class="form-control">
                        @if(!empty($user))
                            @foreach($user as $key => $value)
                                @if($defaultUserId === $key)
                                    <option value="{{ $key }}" selected>{{ $value }}</option>
                                @else
                                    <option value="{{ $key }}">{{ $value }}</option>
                                @endif
                            @endforeach
                        @endif
                    </select>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" onclick="taskForward({{ $id }})">提交</button>
            </div>
        </div>
    </div>
</div>
<script>
    function taskForward(id)
    {
        ajaxPostFunc('/admin/ajax/taskForward', {
            id: id,
            follow_user_id:$("select[name='followUserId"+id+"'] option:selected").val(),
            _token: $.admin.token
        }, {}, res => {
            console.log(res);
            window.location.reload();
        });
    }
</script>
